/**
 * \class adc.h
 * \brief
 * \date 16/04/2009
 * \version 1
 * \author Joao Marcelo Fachinetto
*/

#ifndef ADC_H_
#define ADC_H_

#include "io.h"
#include "irq.h"

#define HWND_ADC0 5

enum VccReference
{
  InternalOFF = 0,
  VccWithExternalCapacitor = 0x40,
  Internal_2_56V_ReferenceWithExternalCapacitor = 0xC0
};

enum DivisionFactor
{
  DivFactor2 = 0x00,
  DivFactor2b1 = 0x01,
  DivFactor4 = 0x02,
  DivFactor8 = 0x03,
  DivFactor16 = 0x04,
  DivFactor32 = 0x05,
  DivFactor64 = 0x06,
  DivFactor128 = 0x07
};

typedef struct ADCCHANNEL
{
  char *Description;
  BYTE Channel;
  enum VccReference VccRef;
  enum DivisionFactor DivFactor;
  BOOL LeftAdjustResult;
  void (*Handler)();
}AdcChannel;

extern void addAdcChannel(AdcChannel *Channel);
extern void enableADC(BYTE Channel);
extern void onADC0Data(void (*Handler));
extern void reconfigureADC();


#endif /* ADC_H_ */
